home *** CD-ROM | disk | FTP | other *** search
- /**
- * Scout - The Amiga System Monitor
- *
- *------------------------------------------------------------------
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * You must not use this source code to gain profit of any kind!
- *
- *------------------------------------------------------------------
- *
- * @author Andreas Gelhausen
- * @author Richard Körber <rkoerber@gmx.de>
- */
-
- #include "system_headers.h"
-
- extern UBYTE *GetCxNodeType( UBYTE type );
-
- static struct LongFlag brokerFlags[] = {
- { 1, "<unknown>", "%00000001" },
- { COF_ACTIVE, "COF_ACTIVE", "%00000010" },
- { COF_SHOW_HIDE, "COF_SHOW_HIDE", "%00000100" },
- { 0, NULL, NULL}
- };
-
- static __asm __saveds LONG cxsublist_con2func(register __a2 Object *obj, register __a1 struct NList_ConstructMessage *msg, register __a0 struct Hook *hook)
- {
- return AllocListEntry(msg->pool, msg->entry, sizeof(struct CxSubEntry));
- }
-
- MakeHook(cxsublist_con2hook, cxsublist_con2func);
-
- static __asm __saveds LONG cxsublist_des2func(register __a2 Object *obj, register __a1 struct NList_DestructMessage *msg, register __a0 struct Hook *hook)
- {
- FreeListEntry(msg->pool, &msg->entry);
-
- return 0;
- }
-
- MakeHook(cxsublist_des2hook, cxsublist_des2func);
-
- static __asm __saveds LONG cxsublist_dsp2func(register __a2 Object *obj, register __a1 struct NList_DisplayMessage *msg, register __a0 struct Hook *hook)
- {
- struct CxSubEntry *cxse = (struct CxSubEntry *)msg->entry;
-
- if (cxse) {
- msg->strings[0] = cxse->cxse_Address;
- msg->strings[1] = cxse->cxse_Type;
- msg->strings[2] = cxse->cxse_Pri;
- } else {
- msg->strings[0] = MUIX_B "Address";
- msg->strings[1] = MUIX_B "ln_Type";
- msg->strings[2] = MUIX_B "ln_Pri";
- }
-
- return 0;
- }
-
- MakeHook(cxsublist_dsp2hook, cxsublist_dsp2func);
-
- static void SetDetails( struct IClass *cl,
- Object *obj,
- struct CxEntry *cxe )
- {
- struct CommoditiesDetailWinData *cdwd = INST_DATA(cl, obj);
- BOOL found = FALSE;
- struct MsgPort *cxport;
-
- if (cxport = CreateMsgPort()) {
- struct NewBroker cxnewbroker = { NB_VERSION, "« Scout Dummy »", "« Scout Dummy »", "Dummy Broker", 0, 0, 0, NULL, 0 };
- struct PrivateCxObj *cxbroker;
-
- cxnewbroker.nb_Port = cxport;
-
- if (cxbroker = (struct PrivateCxObj *)CxBroker(&cxnewbroker, NULL)) {
- struct List *cxlist;
- struct PrivateCxObj *mco;
-
- Forbid();
-
- cxlist = FindListOfNode((struct Node *)cxbroker);
- ITERATE_LIST(cxlist, struct PrivateCxObj *, mco) {
- if (mco == cxe->cxe_Addr) {
- found = TRUE;
- break;
- }
- }
-
- if (found) {
- struct Node *node;
- UBYTE flags[16];
- struct MinList tmplist;
- struct CxSubEntry *cxse, *_cxse;
-
- Flags2BinStr(mco->mco_Flags, flags, sizeof(flags));
-
- GetTaskName(mco->mco_Task, cdwd->cdwd_CxTaskName, sizeof(cdwd->cdwd_CxTaskName));
- MySetContents(cdwd->cdwd_CxSubMoreText[0], "%s", mco->mco_Name);
- MySetContents(cdwd->cdwd_CxSubMoreText[1], "%s", mco->mco_Title);
- MySetContents(cdwd->cdwd_CxSubMoreText[2], "%s", mco->mco_Descr);
- MySetContents(cdwd->cdwd_CxSubMoreText[3], MUIX_R "$%08lx\n" MUIX_C "%s\n%ld\n" MUIX_R "$%08lx\n$%08lx", mco, GetCxNodeType(CxObjType((CxObj *)mco)), mco->mco_Node.ln_Pri, mco->mco_Task, mco->mco_Port);
- MySetContents(cdwd->cdwd_CxSubMoreText[4], MUIX_B "%s", flags);
- MySetContentsHealed(cdwd->cdwd_CxSubMoreText[5], "%s", cdwd->cdwd_CxTaskName);
-
- NewList((struct List *)&tmplist);
-
- ApplicationSleep(TRUE);
-
- set(cdwd->cdwd_CxSubList, MUIA_NList_Quiet, TRUE);
- DoMethod(cdwd->cdwd_CxSubList, MUIM_NList_Clear);
-
- Forbid();
-
- ITERATE_LIST(&mco->mco_SubList, struct Node *, node) {
- if (cxse = AllocVec(sizeof(struct CxSubEntry), MEMF_PUBLIC)) {
- _snprintf(cxse->cxse_Address, sizeof(cxse->cxse_Address), "$%08lx", node);
- stccpy(cxse->cxse_Type, GetCxNodeType(CxObjType((CxObj *)node)), sizeof(cxse->cxse_Type));
- _snprintf(cxse->cxse_Pri, sizeof(cxse->cxse_Pri), "%4ld", node->ln_Pri);
-
- AddTail((struct List *)&tmplist, (struct Node *)cxse);
- }
- }
-
- Permit();
-
- ITERATE_CHANGING_LIST(&tmplist, struct CxSubEntry *, cxse, _cxse) {
- InsertBottomEntry(cdwd->cdwd_CxSubList, cxse);
- FreeVec(cxse);
- }
-
- set(cdwd->cdwd_CxSubList, MUIA_NList_Quiet, FALSE);
-
- ApplicationSleep(FALSE);
-
- set(obj, MUIA_Window_Title, MyGetChildWindowTitle("COMMODITY", cxe->cxe_Name, cdwd->cdwd_Title, sizeof(cdwd->cdwd_Title)));
- }
-
- Permit();
-
- DeleteCxObjAll((CxObj *)cxbroker);
- }
-
- DeleteMsgPort(cxport);
- }
- }
-
- static ULONG __saveds mNew( struct IClass *cl,
- Object *obj,
- struct opSet *msg )
- {
- APTR cxmoretext[6], cxsublist;
-
- if (obj = (Object *)DoSuperNew(cl, obj,
- MUIA_HelpNode, ClassesText,
- MUIA_Window_ID, MakeID('.','C','X','X'),
- WindowContents, VGroup,
-
- Child, ColGroup(2),
- Child, MyLabel2("Name:"),
- Child, cxmoretext[0] = MyTextObject(),
- Child, MyLabel2("Title:"),
- Child, cxmoretext[1] = MyTextObject(),
- Child, MyLabel2("Descr:"),
- Child, cxmoretext[2] = MyTextObject(),
- End,
- Child, HGroup, MUIA_Group_SameWidth, TRUE,
- Child, ColGroup(2),
- Child, MyLabel2("Address:\nType:\nPri:\nTask:\nPort:"),
- Child, cxmoretext[3] = MyTextObject2(),
- Child, MyLabel2("Flags:"),
- Child, cxmoretext[4] = MakeButton(""),
- End,
- Child, ColGroup(2),
- Child, MyLabel2("\nSub CxObj:\n\n\n\n"),
- Child, cxsublist = MyNListviewObject(MakeID('.','C','L','V'), "BAR,BAR P=" MUIX_C ",BAR P=" MUIX_R, &cxsublist_con2hook, &cxsublist_des2hook, &cxsublist_dsp2hook, NULL, FALSE),
- End,
- End,
- Child, HGroup,
- Child, MyLabel2("TaskName:"),
- Child, cxmoretext[5] = MyTextObject(),
- End,
- End,
- TAG_MORE, msg->ops_AttrList))
- {
- struct CommoditiesDetailWinData *cdwd = INST_DATA(cl, obj);
- APTR parent;
-
- cdwd->cdwd_CxSubList = cxsublist;
- CopyMem(cxmoretext, cdwd->cdwd_CxSubMoreText, sizeof(cdwd->cdwd_CxSubMoreText));
-
- parent = (APTR)GetTagData(MUIA_Window_ParentWindow, (ULONG)NULL, msg->ops_AttrList);
-
- set(obj, MUIA_Window_ActiveObject, cxmoretext[4]);
-
- DoMethod(parent, MUIM_Window_AddChildWindow, obj);
- DoMethod(obj, MUIM_Notify, MUIA_Window_CloseRequest, TRUE, MUIV_Notify_Application, 5, MUIM_Application_PushMethod, parent, 2, MUIM_Window_RemChildWindow, obj);
- DoMethod(cxmoretext[4], MUIM_Notify, MUIA_Pressed , FALSE, obj, 1, MUIM_CommoditiesDetailWin_CxFlagsMore);
- }
-
- return (ULONG)obj;
- }
-
- static ULONG __saveds mDispose( struct IClass *cl,
- Object *obj,
- struct opSet *msg )
- {
- struct CommoditiesDetailWinData *cdwd = INST_DATA(cl, obj);
-
- set(obj, MUIA_Window_Open, FALSE);
- DoMethod(cdwd->cdwd_CxSubList, MUIM_NList_Clear);
-
- return (DoSuperMethodA(cl, obj, msg));
- }
-
- static ULONG __saveds mSet( struct IClass *cl,
- Object *obj,
- Msg msg )
- {
- struct CommoditiesDetailWinData *cdwd = INST_DATA(cl, obj);
- struct TagItem *tags, *tag;
-
- for (tags = ((struct opSet *)msg)->ops_AttrList; tag = NextTagItem(&tags); ) {
- switch (tag->ti_Tag) {
- case MUIA_Window_ParentWindow:
- DoMethod(obj, MUIM_Notify, MUIA_Window_CloseRequest, TRUE, MUIV_Notify_Application, 5, MUIM_Application_PushMethod, (APTR)tag->ti_Data, 2, MUIM_Window_RemChildWindow, obj);
- break;
-
- case MUIA_CommoditiesDetailWin_Commodity:
- cdwd->cdwd_Commodity = (struct CxEntry *)tag->ti_Data;
- SetDetails(cl, obj, (struct CxEntry *)tag->ti_Data);
- break;
- }
- }
-
- return (DoSuperMethodA(cl,obj,msg));
- }
-
- static ULONG __saveds mCxFlagsMore( struct IClass *cl,
- Object *obj,
- Msg msg )
- {
- struct CommoditiesDetailWinData *cdwd = INST_DATA(cl, obj);
- APTR flagsWin;
-
- if (flagsWin = FlagsWindowObject,
- MUIA_Window_Title, "Commodity Flags",
- MUIA_Window_ParentWindow, obj,
- End) {
- DoMethod(flagsWin, MUIM_FlagsWin_ShowFlags, cdwd->cdwd_Commodity->cxe_Addr->mco_Flags, MUIV_FlagsWin_FlagsType_Byte, brokerFlags, NULL, "bc_Flags");
- }
-
- return 0;
- }
-
- ULONG __asm __saveds CommoditiesDetailWinDispatcher( register __a0 struct IClass *cl,
- register __a2 Object *obj,
- register __a1 Msg msg )
- {
- switch (msg->MethodID) {
- case OM_NEW: return (mNew(cl, obj, (APTR)msg));
- case OM_DISPOSE: return (mDispose(cl, obj, (APTR)msg));
- case OM_SET: return (mSet(cl, obj, (APTR)msg));
- case MUIM_CommoditiesDetailWin_CxFlagsMore: return (mCxFlagsMore(cl, obj, (APTR)msg));
- }
-
- return (DoSuperMethodA(cl, obj, msg));
- }
-
-